<template>
  <div class="container">
    <baleTable
      :tableData="tableData"
      :tableHead="tableHead"
      :isSearch="true"
      :tableLoading="tableLoading"
      :page="page"
      @pageSizeChange="pageSizeChange"
      @handleCurrentChange="handleCurrentChange"
      @searchMethods="searchMethods"
      @tableSortChange="tableSortChange"
      ref="baleTable"
    >
      <!--      <template #icon="{ scope }">
        <div @click.stop="">
          <tablePrImg v-if="scope.row.icon" :imgSrc="scope.row.icon" :prImgList="[scope.row.icon]" />
        </div>
      </template> -->
      <template #pic="{ scope }">
        <div @click.stop="" style="display: flex" v-if="scope.row.pic">
          <div
            v-for="item in scope.row.pic.split(',')"
            :key="item"
            style="margin-left: 15px"
          >
            <tablePrImg :imgSrc="item" :prImgList="[item]" />
          </div>
        </div>
      </template>
      <!-- 等级 -->
      <template #skill="{ scope }">
        {{ formmateSkill(scope.row.skill) }}
      </template>
      <template #status="{ scope }">
        <el-tag type="danger" v-if="scope.row.status == '待处理'">{{
          scope.row.status
        }}</el-tag>
        <el-tag type="success" v-else>{{ scope.row.status }}</el-tag>
      </template>
      <!--  <template #type="{ scope }"> 服务质量 </template> -->
      <template #caozuo="{ scope }">
        <el-button type="primary" size="mini" @click="showDialog(scope.row)"
          >处理</el-button
        >
      </template>
    </baleTable>
    <detail
      ref="orderDetail"
      @refresh="handleSelectTableType(tableType)"
    ></detail>
    <el-dialog
      :visible.sync="dialogVisible"
      width="800px"
      :before-close="handleClose"
      :close-on-click-modal="false"
      append-to-body
      title="投诉处理"
    >
      <el-input
        type="textarea"
        placeholder="请输入内容"
        v-model="textarea"
        maxlength="30"
        rows="10"
        show-word-limit
      >
      </el-input>
      <div slot="footer" class="tx-c">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="confirm('')" :loading="btnLoading"
          >确定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  ApiGetComplaint,
  ApiPosthandle,
  ApiDoctorDel,
  ApiResetPassword,
  Apiitem,
} from "@a/index";
import { tableHead } from "./config";
import tablePrImg from "@/components/tablePrImg.vue";
//获取用户列表数据
/* import userList from "./component/userList.vue"; */
export default {
  components: {
    tablePrImg,
    /*   userList, */
  },
  data() {
    return {
      tableHead,
      tableData: [],
      page: {
        page: 1,
        size: 25,
        total: 0,
      },
      textarea: "",
      tableLoading: false,
      searchParams: {},
      sortParams: {},
      editFormVisible: false,
      btnLoading: false,
      catList: [],
      dialogVisible: false,
      id: null,
    };
  },
  mounted() {
    this.getTableData();
  },
  methods: {
    confirm() {
      ApiPosthandle({ id: this.id, handle: this.textarea }).then((res) => {
        this.$message.success("操作成功！");
        this.handleClose();
        this.textarea = "";
        this.getTableData();
      });
    },
    handleClose() {
      this.dialogVisible = false;
    },
    showDialog(row) {
      this.id = row.id;
      this.dialogVisible = true;
    },
    getTableData(params = {}) {
      let postParams = {
        ...params,
        ...this.searchParams,
        ...this.sortParams,
        ...this.page,
      };
      this.tableLoading = true;
      ApiGetComplaint(postParams).then((res) => {
        let { data, page } = res;
        this.tableData = data;
        this.page.total = page.total;
        this.tableLoading = false;
      });
    },
    searchMethods(params) {
      this.searchParams = {};
      this.page.page = 1;
      this.searchParams = params;
      this.getTableData();
    },
    pageSizeChange(val) {
      this.page.size = val;
      this.getTableData();
    },
    handleCurrentChange(val) {
      this.page.page = val;
      this.getTableData();
    },
    tableSortChange(params) {
      if (params.sort_str) {
        this.sortParams = { ...this.sortParams, ...params };
      } else {
        delete this.sortParams.sort_str;
        delete this.sortParams.sort_order;
      }
      this.page.page = 1;
      this.getTableData();
    },
  },
  filters: {},
};
</script>

<style lang="less" scoped></style>
